home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.002 / stk-3 / STk-3.1 / Tcl / tclWinPort.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-31  |  8.0 KB  |  368 lines

  1. /*
  2.  * tclWinPort.h --
  3.  *
  4.  *    This header file handles porting issues that occur because of
  5.  *    differences between Windows and Unix. It should be the only
  6.  *    file that contains #ifdefs to handle different flavors of OS.
  7.  *
  8.  * Copyright (c) 1994-1996 Sun Microsystems, Inc.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * SCCS: @(#) tclWinPort.h 1.32 96/03/25 17:14:38
  14.  */
  15.  
  16. #ifndef _TCLWINPORT
  17. #define _TCLWINPORT
  18.  
  19. #include <malloc.h>
  20. #include <stdio.h>
  21.  
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <errno.h>
  25. #include <process.h>
  26. #include <signal.h>
  27. #include <winsock.h>
  28. #include <sys/stat.h>
  29. #include <sys/timeb.h>
  30. #include <time.h>
  31. #include <io.h>
  32. #include <fcntl.h>
  33.  
  34. #define WIN32_LEAN_AND_MEAN
  35. #include <windows.h>
  36. #undef WIN32_LEAN_AND_MEAN
  37.  
  38. /*
  39.  * Define EINPROGRESS in terms of WSAEINPROGRESS.
  40.  */
  41.  
  42. #ifndef    EINPROGRESS
  43. #define EINPROGRESS WSAEINPROGRESS
  44. #endif
  45.  
  46. /*
  47.  * If ENOTSUP is not defined, define it to a value that will never occur.
  48.  */
  49.  
  50. #ifndef ENOTSUP
  51. #define    ENOTSUP        -1030507
  52. #endif
  53.  
  54. /*
  55.  * The default platform eol translation on Windows is TCL_TRANSLATE_CRLF:
  56.  */
  57.  
  58. #define    TCL_PLATFORM_TRANSLATION    TCL_TRANSLATE_CRLF
  59.  
  60. /*
  61.  * Declare dynamic loading extension macro.
  62.  */
  63.  
  64. #define TCL_SHLIB_EXT ".dll"
  65.  
  66. /*
  67.  * Supply definitions for macros to query wait status, if not already
  68.  * defined in header files above.
  69.  */
  70.  
  71. #if TCL_UNION_WAIT
  72. #   define WAIT_STATUS_TYPE union wait
  73. #else
  74. #   define WAIT_STATUS_TYPE int
  75. #endif
  76.  
  77. #ifndef WIFEXITED
  78. #   define WIFEXITED(stat)  (((*((int *) &(stat))) & 0xff) == 0)
  79. #endif
  80.  
  81. #ifndef WEXITSTATUS
  82. #   define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff)
  83. #endif
  84.  
  85. #ifndef WIFSIGNALED
  86. #   define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff)))
  87. #endif
  88.  
  89. #ifndef WTERMSIG
  90. #   define WTERMSIG(stat)    ((*((int *) &(stat))) & 0x7f)
  91. #endif
  92.  
  93. #ifndef WIFSTOPPED
  94. #   define WIFSTOPPED(stat)  (((*((int *) &(stat))) & 0xff) == 0177)
  95. #endif
  96.  
  97. #ifndef WSTOPSIG
  98. #   define WSTOPSIG(stat)    (((*((int *) &(stat))) >> 8) & 0xff)
  99. #endif
  100.  
  101. /*
  102.  * Define constants for waitpid() system call if they aren't defined
  103.  * by a system header file.
  104.  */
  105.  
  106. #ifndef WNOHANG
  107. #   define WNOHANG 1
  108. #endif
  109. #ifndef WUNTRACED
  110. #   define WUNTRACED 2
  111. #endif
  112.  
  113. /*
  114.  * Define MAXPATHLEN in terms of MAXPATH if available
  115.  */
  116.  
  117. #ifndef MAXPATH
  118. #define MAXPATH MAX_PATH
  119. #endif /* MAXPATH */
  120.  
  121. #ifndef MAXPATHLEN
  122. #define MAXPATHLEN MAXPATH
  123. #endif /* MAXPATHLEN */
  124.  
  125. #ifndef F_OK
  126. #    define F_OK 00
  127. #endif
  128. #ifndef X_OK
  129. #    define X_OK 01
  130. #endif
  131. #ifndef W_OK
  132. #    define W_OK 02
  133. #endif
  134. #ifndef R_OK
  135. #    define R_OK 04
  136. #endif
  137.  
  138. /*
  139.  * On systems without symbolic links (i.e. S_IFLNK isn't defined)
  140.  * define "lstat" to use "stat" instead.
  141.  */
  142.  
  143. #ifndef S_IFLNK
  144. #   define lstat stat
  145. #endif
  146.  
  147. /*
  148.  * Define macros to query file type bits, if they're not already
  149.  * defined.
  150.  */
  151.  
  152. #ifndef S_ISREG
  153. #   ifdef S_IFREG
  154. #       define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  155. #   else
  156. #       define S_ISREG(m) 0
  157. #   endif
  158. # endif
  159. #ifndef S_ISDIR
  160. #   ifdef S_IFDIR
  161. #       define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  162. #   else
  163. #       define S_ISDIR(m) 0
  164. #   endif
  165. # endif
  166. #ifndef S_ISCHR
  167. #   ifdef S_IFCHR
  168. #       define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  169. #   else
  170. #       define S_ISCHR(m) 0
  171. #   endif
  172. # endif
  173. #ifndef S_ISBLK
  174. #   ifdef S_IFBLK
  175. #       define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  176. #   else
  177. #       define S_ISBLK(m) 0
  178. #   endif
  179. # endif
  180. #ifndef S_ISFIFO
  181. #   ifdef S_IFIFO
  182. #       define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  183. #   else
  184. #       define S_ISFIFO(m) 0
  185. #   endif
  186. # endif
  187. #ifndef S_ISLNK
  188. #   ifdef S_IFLNK
  189. #       define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  190. #   else
  191. #       define S_ISLNK(m) 0
  192. #   endif
  193. # endif
  194. #ifndef S_ISSOCK
  195. #   ifdef S_IFSOCK
  196. #       define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  197. #   else
  198. #       define S_ISSOCK(m) 0
  199. #   endif
  200. # endif
  201.  
  202. /*
  203.  * Define pid_t and uid_t if they're not already defined.
  204.  */
  205.  
  206. #if ! TCL_PID_T
  207. #   define pid_t int
  208. #endif
  209. #if ! TCL_UID_T
  210. #   define uid_t int
  211. #endif
  212.  
  213. /*
  214.  * Provide an implementation of TclSetSystemEnv in terms of the equivalent
  215.  * Win32 call.
  216.  */
  217.  
  218. #define TclSetSystemEnv(a,b) SetEnvironmentVariable(a,b)
  219.  
  220. /*
  221.  * Provide a stub definition for TclGetUserHome().
  222.  */
  223.  
  224. #define TclGetUserHome(name,bufferPtr) (NULL)
  225.  
  226. /*
  227.  * Visual C++ has some odd names for common functions, so we need to
  228.  * define a few macros to handle them.  Also, it defines EDEADLOCK and
  229.  * EDEADLK as the same value, which confuses Tcl_ErrnoId().
  230.  */
  231.  
  232. #ifdef _MSC_VER
  233. #    define environ _environ
  234. #    define hypot _hypot
  235. #    define exception _exception
  236. #    undef EDEADLOCK
  237. #endif /* _MSC_VER */
  238.  
  239. /*
  240.  * The following defines redefine the Windows Socket errors as
  241.  * BSD errors so Tcl_PosixError can do the right thing.
  242.  */
  243.  
  244. #ifndef EWOULDBLOCK
  245. #define EWOULDBLOCK             EAGAIN
  246. #endif
  247. #ifndef EALREADY
  248. #define EALREADY    149    /* operation already in progress */
  249. #endif
  250. #ifndef ENOTSOCK
  251. #define ENOTSOCK    95    /* Socket operation on non-socket */
  252. #endif
  253. #ifndef EDESTADDRREQ
  254. #define EDESTADDRREQ    96    /* Destination address required */
  255. #endif
  256. #ifndef EMSGSIZE
  257. #define EMSGSIZE    97    /* Message too long */
  258. #endif
  259. #ifndef EPROTOTYPE
  260. #define EPROTOTYPE    98    /* Protocol wrong type for socket */
  261. #endif
  262. #ifndef ENOPROTOOPT
  263. #define ENOPROTOOPT    99    /* Protocol not available */
  264. #endif
  265. #ifndef EPROTONOSUPPORT
  266. #define EPROTONOSUPPORT    120    /* Protocol not supported */
  267. #endif
  268. #ifndef ESOCKTNOSUPPORT
  269. #define ESOCKTNOSUPPORT    121    /* Socket type not supported */
  270. #endif
  271. #ifndef EOPNOTSUPP
  272. #define EOPNOTSUPP    122    /* Operation not supported on socket */
  273. #endif
  274. #ifndef EPFNOSUPPORT
  275. #define EPFNOSUPPORT    123    /* Protocol family not supported */
  276. #endif
  277. #ifndef EAFNOSUPPORT
  278. #define EAFNOSUPPORT    124    /* Address family not supported */
  279. #endif
  280. #ifndef EADDRINUSE
  281. #define EADDRINUSE    125    /* Address already in use */
  282. #endif
  283. #ifndef EADDRNOTAVAIL
  284. #define EADDRNOTAVAIL    126    /* Can't assign requested address */
  285. #endif
  286. #ifndef ENETDOWN
  287. #define ENETDOWN    127    /* Network is down */
  288. #endif
  289. #ifndef ENETUNREACH
  290. #define ENETUNREACH    128    /* Network is unreachable */
  291. #endif
  292. #ifndef ENETRESET
  293. #define ENETRESET    129    /* Network dropped connection on reset */
  294. #endif
  295. #ifndef ECONNABORTED
  296. #define ECONNABORTED    130    /* Software caused connection abort */
  297. #endif
  298. #ifndef ECONNRESET
  299. #define ECONNRESET    131    /* Connection reset by peer */
  300. #endif
  301. #ifndef ENOBUFS
  302. #define ENOBUFS        132    /* No buffer space available */
  303. #endif
  304. #ifndef EISCONN
  305. #define EISCONN        133    /* Socket is already connected */
  306. #endif
  307. #ifndef ENOTCONN
  308. #define ENOTCONN    134    /* Socket is not connected */
  309. #endif
  310. #ifndef ESHUTDOWN
  311. #define ESHUTDOWN    143    /* Can't send after socket shutdown */
  312. #endif
  313. #ifndef ETOOMANYREFS
  314. #define ETOOMANYREFS    144    /* Too many references: can't splice */
  315. #endif
  316. #ifndef ETIMEDOUT
  317. #define ETIMEDOUT    145    /* Connection timed out */
  318. #endif
  319. #ifndef ECONNREFUSED
  320. #define ECONNREFUSED    146    /* Connection refused */
  321. #endif
  322. #ifndef ELOOP
  323. #define ELOOP        90    /* Symbolic link loop */
  324. #endif
  325. #ifndef EHOSTDOWN
  326. #define EHOSTDOWN    147    /* Host is down */
  327. #endif
  328. #ifndef EHOSTUNREACH
  329. #define EHOSTUNREACH    148    /* No route to host */
  330. #endif
  331. #ifndef ENOTEMPTY
  332. #define ENOTEMPTY     93    /* directory not empty */
  333. #endif
  334. #ifndef EUSERS
  335. #define EUSERS        94    /* Too many users (for UFS) */
  336. #endif
  337. #ifndef EDQUOT
  338. #define EDQUOT        49    /* Disc quota exceeded */
  339. #endif
  340. #ifndef ESTALE
  341. #define ESTALE        151    /* Stale NFS file handle */
  342. #endif
  343. #ifndef EREMOTE
  344. #define EREMOTE        66    /* The object is remote */
  345. #endif
  346.  
  347. /*
  348.  * The following implements the Windows method for exiting the process.
  349.  */
  350. #define TclPlatformExit(status) exit(status)
  351.  
  352.  
  353. /*
  354.  * Declarations for Windows specific functions.
  355.  */
  356.  
  357. EXTERN void        TclWinConvertError _ANSI_ARGS_((DWORD errCode));
  358. EXTERN void        TclWinConvertWSAError _ANSI_ARGS_((DWORD errCode));
  359. EXTERN HINSTANCE    TclWinGetTclInstance _ANSI_ARGS_((void));
  360. EXTERN HINSTANCE    TclWinLoadLibrary _ANSI_ARGS_((char *name));
  361. EXTERN void        TclWinNotifySocket _ANSI_ARGS_((void));
  362. EXTERN int        TclWinSocketReady _ANSI_ARGS_((Tcl_File file,
  363.                 int mask));
  364. EXTERN void        TclWinWatchSocket _ANSI_ARGS_((Tcl_File file,
  365.                 int mask));
  366.  
  367. #endif /* _TCLWINPORT */
  368.